<template>
  <div v-if="info.id">
    <div class="person_info gl_clear">
      <div class="gl_fl">
        <img class="person_face" :src="getStaticPhotoUrl(showInfo.h5ParameterJson.StudentAvatarUrl)">
      </div>
      <div class="person_text">
        <div>
          <div class="paragraph gl_clear">
            <span class="person_name gl_fl">{{ showInfo.h5ParameterJson.StudentName }}</span>
            <span class="person_gender gl_fl">{{ showInfo.h5ParameterJson.Gender }}</span>
          </div>
          <div class="paragraph gl_clear">
            <i class="iconfont icon_daibiaojigou check_icon_org gl_fl" />
            <span class="person_org gl_fl">{{ showInfo.h5ParameterJson.ClubName }}</span>
          </div>
        </div>
      </div>
    </div>
    <div class="check_info">
      <div class="paragraph gl_clear">
        <div class="check_lable gl_fl">{{ checkStr }}时间</div>
        <div class="check_content gl_fl">
          <template v-if="mode === 'IN'">
            {{ checkInTime }}
          </template>
          <template v-if="mode === 'OUT'">
            {{ checkOutTime }}
          </template>
        </div>
      </div>
      <div class="paragraph gl_clear">
        <div class="check_lable gl_fl">上课地址</div>
        <div class="check_content gl_fl">{{ showInfo.h5ParameterJson.ClassroomName }} {{ showInfo.h5ParameterJson.ClassName }}</div>
      </div>
    </div>
    <div class="charge_info">
      <div class="charge_title">{{ checkStr }}负责人</div>
      <div class="coach_wrap">
        <div class="coach_item gl_clear">
          <div class="coach_info gl_fl">
            <div class="charge_paragraph gl_clear">
              <div class="check_lable gl_fl">教练</div>
              <div class="check_content gl_fl">{{ showInfo.h5ParameterJson.CoachName }}</div>
            </div>
            <div class="charge_paragraph gl_clear">
              <div class="check_lable gl_fl">电话</div>
              <div class="check_content gl_fl">{{ showInfo.h5ParameterJson.PhoneNumber }}</div>
            </div>
          </div>
          <img v-if="showInfo.h5ParameterJson.CoachAvatarUrl" class="coach_face gl_fr" :src="getStaticPhotoUrl(showInfo.h5ParameterJson.CoachAvatarUrl)">
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    info: {
      type: Object,
      default () {
        return {};
      }
    },
    mode: { // IN or OUT
      type: String,
      default: 'IN'
    }
  },
  computed: {
    showInfo () {
      return this.info.id ? this.info : {};
    },
    checkStr () {
      if (this.mode === 'IN') {
        return '签到';
      }
      if (this.mode === 'OUT') {
        return '签退';
      }
      return '';
    },
    checkInTime () {
      let _date = '';
      let _time = '';
      try {
        const _checkInTime = this.showInfo.h5ParameterJson.CheckInTime;
        _date = _checkInTime.slice(0, 10).replace(/-/g, '.');
        _time = _checkInTime.slice(11, 16);
      } catch (error) {
        console.log(error);
      }
      return `${_date} ${_time}`;
    },
    checkOutTime () {
      let _date = '';
      let _time = '';
      try {
        const _checkOutTime = this.showInfo.h5ParameterJson.CheckOutTime;
        _date = _checkOutTime.slice(0, 10).replace(/-/g, '.');
        _time = _checkOutTime.slice(11, 16);
      } catch (error) {
        console.log(error);
      }
      return `${_date} ${_time}`;
    }
  },
  methods: {
    // 获取静态图片地址
    getStaticPhotoUrl(relativeUrl) {
      if (!relativeUrl) return '';
      return WEB_CONFIG.VUE_APP_STATIC_FILE_RUL + relativeUrl;
    }
  }
};
</script>

<style lang="scss" scoped>
  .person_info {
    padding: 0.3rem 0.3rem 0.35rem;
    background-color: #fff;
    border-bottom: 2px solid #d5d5d5;
    overflow: hidden;
  }
  .person_face {
    width: 1.36rem;
    height: 1.90rem;
    vertical-align: top;
    border-radius: 0.08rem;
  }
  .person_text {
    margin-left: 1.66rem;
  }
  .person_name {
    padding-top: 0.24rem;
    margin-right: 0.3rem;
    font-weight: 500;
    font-size: 0.36rem;
    line-height: 0.5rem;
    color: #354569;
    vertical-align: top;
  }
  .person_gender {
    padding-top: 0.36rem;
    font-size: 0.24rem;
    line-height: 0.34rem;
    color: #828282;
    vertical-align: top;
  }
  .check_icon_org {
    margin-right: 0.2rem;
    font-size: 0.24rem;
    color: #FCB428;
  }
  .person_org {
    font-size: 0.24rem;
    line-height: 0.34rem;
    color: #828282;
  }

  .paragraph {
    margin-bottom: 0.3rem;
    overflow: hidden;
  }
  .paragraph:last-child {
    margin-bottom: 0;
  }

  .check_info {
    background-color: #fff;
    padding: 0.5rem 0.5rem 0.6rem;
  }
  .check_lable {
    font-size: 0.24rem;
    line-height: 0.34rem;
    letter-spacing: 1px;
    color: #A2A8A3;
    margin-right: 0.2rem;
  }
  .check_content {
    max-width: 5rem;
    font-size: 0.26rem;
    line-height: 0.36rem;
    color: #353434;
  }

  .charge_title {
    height: 1.03rem;
    padding: 0.4rem 0.26rem 0;
    background-color: #f5f6f7;
    font-size: 0.28rem;
    line-height: 0.39rem;
    color: #000;
  }
  .coach_wrap {
    padding: 0.3rem 0.2rem;
  }
  .coach_item {
    padding: 0.3rem 0.4rem 0.4rem;
    background-color: #fff;
    border-radius: 0.12rem;
    box-shadow: 0 0.02rem 0.15rem rgba(53, 69, 105, 0.1);
  }
  .coach_info {
    padding-top: 0.17rem;
  }
  .charge_info .check_lable {
    margin-right: 0.3rem;
  }
  .charge_paragraph {
    margin-bottom: 0.18rem;
  }
  .charge_paragraph:last-child {
    margin-bottom: 0rem;
  }
  .coach_face {
    width: 0.9rem;
    height: 1.26rem;
    vertical-align: top;
    border-radius: 0.08rem;
  }
</style>
